package cn.gcjxsc.common.consts;

/**
 * @author pumbaa
 * @since 1.0
 */
public enum OrderStatus {
    //待付款
    STATUS_NOT_PAID(0, "待付款"),
    //已付款
    STATUS_PAID(1, "待付款"),
    //已确认
    STATUS_CONFIRMED(2, "已确认"),
    //已发货
    STATUS_SHIPPED(4, "已发货"),
    //已发货
    STATUS_DONE(8, "已完成"),
    //已取消
    STATUS_CANCEL(16, "已取消"),
    //退款
    STATUS_REFUND(32, "退款");

    private int status;
    private String desc;

    OrderStatus(int status, String desc) {
        this.status = status;
        this.desc = desc;
    }

    public int getStatus() {
        return status;
    }

    public String getDesc() {
        return desc;
    }

    public static OrderStatus fromCode(int status) {
        OrderStatus[] values = OrderStatus.values();
        for (OrderStatus value : values) {
            if (value.getStatus() == status) {
                return value;
            }
        }
        return null;
    }
}
